www.gusucode.com > ASP+ACCESS在线手机销售系统(论文+源代码+答辩PPT) > ASP+ACCESS在线手机销售系统(论文+源代码+答辩PPT)\9)ASP 在线手机销售系统\HandsetPro\handset\admin\Include\ProductTypeBase.asp

    <%
	'========================================================
	'
	' 将所有厂商添加到下拉列表框中
	' 说明:这里只添加ProductType表中SuperId=0的记录
	' 参数:
	'	nTypeId:当前选种的厂商名称ID
	'	szCtlName:下拉列表框的名称,在获取表单中的数时用
	'========================================================
	function TypeToSelect(nTypeId, szCtlName)
		dim strSQL
		dim rsType
		dim tempi
		dim nID, szName
		Response.Write	"<SELECT name =""" & szCtlName & """ ID=""Select1"">"
		Response.Write	"<option value = ""0"">全部分类</option>"
		
		strSQL = "SELECT * FROM ProductType WHERE SuperID = 0"
		set rsType = Server.CreateObject("ADODB.RecordSet")
		rsType.Open strSQL, conn, adOpenKeyset, adLockReadOnly 
		if rsType.EOF And rsType.BOF then
			'如果没有检索到产品类型
			Response.Write	"</SELECT>"
			rsType.Close()
			Set rsType = Nothing
			exit function
		else
			do while not rsType.eof 
				nID = rsType("id")
				szName = rsType("name")
				Response.Write "<option value = "& nID
				'如果当前的nID与传入的nTypeId相同,则选中它
				
				if CInt(nID) = CInt(nTypeId) then Response.Write " selected"
				Response.Write ">"
				Response.Write szName &"</option>"
				rsType.MoveNext
			loop
		end if
		Response.Write	"</SELECT>"
		rsType.Close()
		Set rsType = Nothing
		
	end function
%>